<?php
$backgrounds = array("/images/background1.jpg","/images/background1.jpg");
$headerImages = array("/images/banner1.jpg","/images/banner2.jpg");
$headerLogos = array("/images/logo1.gif","/images/logo2.gif");
if(!isset($pageStyleIndex)) {$pageStyleIndex=0; }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title><?php 
                if(isset($pageTitle)) {
                    echo $pageTitle;
                } else {
                    echo "Washington Homebrewers Association";
                }
                ?></title>
        <link href="/styles/nav.css" type="text/css" rel="stylesheet" />
        <link href="/styles/main.css" type="text/css" rel="stylesheet" />
        <link href="/styles/page.css" type="text/css" rel="stylesheet" />
		<link href="/styles/cms.css" type="text/css" rel="stylesheet" />
        <?php 
            if(isset($styleIncludes)) { 
                foreach($styleIncludes as $style) { 
                    echo $style . "\n";
                }
            }
        ?>
        <script type="text/javascript" src="/scripts/comfunc.js"></script>
        <?php 
            if(isset($scriptIncludes)) { 
                foreach($scriptIncludes as $scripts) { 
                    echo $scripts . "\n";
                }
            }
        ?>
        <style type="text/css">
            #firstNav {
                background:transparent url(<?=$headerImages[$pageStyleIndex]?>) repeat-y top center;
            }
            body {
                background:transparent url(<?=$backgrounds[$pageStyleIndex]?>) repeat-y top center;
            }
        </style>
    </head>
    <body>
		<?/*
		<div id="edit-bar">
			Edit This Page
		</div>
		*/ ?>
        <div id="page">
            <div id="header">
                <div id="firstNav">
                    <div class="col1">
                        <a href="/">
                            <img src="<?=$headerLogos[$pageStyleIndex]?>" alt="Washington Homebrewers Association Logo" />
                        </a>
                    </div>
                    <div class="col2" id="nav">
                        <ul>
                            <? 
                               $navArr = $this->config->item('main_nav');
                               if(isset($navArr)) {
                                    if(!isset($selectedNav) || $selectedNav=="") { 
                                        $selectedNav=-1;
                                    }
                                    for($i=0;$i<count($navArr);$i++) { 
                                        $topLevelKeys = array_keys($navArr);
                                        list($label,$title,$url,$access) = explode("|",$topLevelKeys[$i]);
                                        if($selectedNav!=$i){
                                        ?>
                                        <li><a href="<?=$url ?>" title="<?= $title ?>"><?=$label?></a></li>
                                        <? } else {// end if selectedNav==$i ?>
                                        <li class="active"><a href="<?=$url ?>" title="<?=$title ?>"><?=$label?></a></li>
                                       <? }
                                    } // end for loop 
                                } // end if nav is set 
                            ?>
                        </ul>
                    </div>
                    <div class="col3">
                        <div style="background-color:#ffffff;text-align:center;padding:5px 0px;">
                            <?php if(!$this->profile->isLoggedIn()): ?>
                            <a href="/account/">Login</a> or <a href="/account/create/">Create an account</a>
                            <?php else: ?>
                            <a href="/account/">My Account</a> | <a href="/account/logout/">Logoff?</a>
                            <?php endif; ?>
                        </div>
                        <div id="events">
                            <div class="header">
                                <h4 style="float:left;"><a href="/events/">Events</a></h4>
								<?php if($this->profile->isLoggedIn()): ?>
                                <div style="float:right;"><a href="/events/create/">Add</a></div>
								<?php endif;?>
                                <div class="cleardiv"></div>
                            </div>
                            <div>
                                <?
                                    $this->load->model("EventsModel");
                                    $this->load->plugin("event_quicklist");
                                    displayEvents(6);
                                ?>
                            </div>
                        </div>
                    </div>
                    <div class="cleardiv"></div>
                </div>
                <div id="secondaryNav">
                    <div class="col1" style="text-align:center;">
                        <div class="col-padding">
                            <?php /* also need to see if user has a club too */ ?>
                            <?php if($this->profile->isLoggedIn() && $this->profile->hasClubs()): ?>
                            Find a Mentor | <a href="/clubs/my">My Clubs</a>
                            <?php else: ?>
                            Find a Mentor | <a href="/clubs/find">Join a Club</a>
                            <?php endif; ?>
                        </div>
                    </div>
                    <div class="col2">
                        <div class="col-padding" id="secondaryNavList">
                           <?
                           if(isset($navArr)) {
                                if(isset($selectedNav) && $selectedNav>=0) { 
                                    $topLevelKeys = array_keys($navArr);
                                    $secondaryNav = $navArr[$topLevelKeys[$selectedNav]];
                                    for($i=0;$i<count($secondaryNav);$i++) { 
                                       list($label,$title,$url,$access) = explode("|",$secondaryNav[$i]);
                                       if(isset($selectedSecondNav) && $selectedSecondNav==$i) { ?>
                                            <span title="<?=$title?>"><?=$label?></span>
                                            <? } else { ?>
                                            <a href="<?=$url?>" title="<?=$title?>"><?=$label?></a>
                                            <? }?>
                                        <? if($i+1<count($secondaryNav)) { ?>
                                            |
                                       <? }
                                    } // end for loop
                                } // end if has selectedIndex
                            } // end if nav is set
                            ?>
                        </div>
                    </div>
                    <div class="col3" style="">
                        <div class="col-padding">
                            <? if(isset($sNavCallout)) {
                                    echo $sNavCallout;
                                } else { 
                                    echo "<p>&nbsp;</p>";
                                }
                            ?>
                        </div>
                    </div>
                    <div style="clear:left;"></div>
                </div>
            </div>
            <div style="clear:left;"></div>